package com.example.web.controller;

import com.example.common.Interface.checkout.entity.dto.CheckoutReqDTO;
import com.example.common.Interface.checkout.entity.dto.CheckoutRespDTO;
import com.example.common.Interface.checkout.service.CheckoutService;
import com.example.common.response.ResponseResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkout")
public class CheckoutController {

    @DubboReference(check = false)
    private CheckoutService checkoutService;

    /**
     * 处理结账请求
     * @param checkoutReq 结账请求数据传输对象
     * @return 结账响应数据传输对象
     */
    @PostMapping("/checkout")
    public ResponseResult<CheckoutRespDTO> checkout(@RequestBody CheckoutReqDTO checkoutReq) {
        return ResponseResult.success(checkoutService.checkout(checkoutReq));
    }
}